package com.easy.controller;

import com.easy.bean.User;
import com.easy.service.IShoppingLoginService;
import com.easy.util.LayData;
import com.easy.util.SYS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
public class LoginController {
    @Autowired
    IShoppingLoginService loginService;

    @RequestMapping("shopping/dologin")
    @ResponseBody
    public LayData shoppingLogin(User user, HttpSession session) {
        //执行登录业务
        User u = loginService.dologin(user);
        //记录登录状态
        session.setAttribute(SYS.SHOPPING_LOGIN_USER, u);
        return LayData.success(200, "登陆成功");
    }

    @RequestMapping("system/dologin")
    public String systemLogin() {
        return "success";
    }
}
